//
//  PhotoDetailViewController.m
//  CommonFrame
//
//  Created by Bang-guo on 15/7/23.
//  Copyright (c) 2015年 guobang. All rights reserved.
//

#import "PhotoDetailViewController.h"

@interface PhotoDetailViewController ()

@end

@implementation PhotoDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    NearbyPhoto *photo = self.photoArray[self.intNum];
    
    self.navigationItem.title = photo.trip_name;
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    //设置item大小
    flowLayout.itemSize = CGSizeMake(WIDTH, HEIGHT - 113);
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    //距离边界的间距 上 左 下 右
    flowLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    //列间距
    flowLayout.minimumInteritemSpacing = 0;
    //行间距
    flowLayout.minimumLineSpacing = 0;

    self.photoCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT - 113) collectionViewLayout:flowLayout];
    self.photoCollectionView.delegate = self;
    self.photoCollectionView.dataSource = self;
    self.photoCollectionView.backgroundColor = [UIColor blackColor];
    //注册方法
    [self.photoCollectionView registerClass:[PhotoDetailTableViewCell class] forCellWithReuseIdentifier:@"reuse"];
    [self.view addSubview:self.photoCollectionView];
    [self.photoCollectionView setContentOffset:CGPointMake(WIDTH * self.intNum, 0)];
    self.photoCollectionView.pagingEnabled = YES;
    
}


//设置多个分区个数
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}




//设置item的个数
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.photoArray.count;
}

//布局item
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    //直接从系统的重用池里取ite
    PhotoDetailTableViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse" forIndexPath:indexPath];
    
    NearbyPhoto *photo = self.photoArray[indexPath.row];
    
    cell.photo = photo;
    self.navigationItem.title = photo.trip_name;
    
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
